<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../../static/lib/layuiadmin/layui/css/layui.css" media="all">
</head>
<body>
<div id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn" style="margin-left: 10px;"  onclick="getCheckData();">确定</button>
        <span style=" margin-left: 110px; font-size: 16px">系统找到多个下一活动！请手动选择下一活动！</span>
    </div>
</div>
<table id="formField" lay-filter="formField" style=" width: 100%;">
    <thead>
    <tr>
        <th lay-data="{type:'radio',width:'7%'}"></th>
        <th lay-data="{field:'activityName',width:'93%',align:'center'}">活动名称</th>
    </tr>
    </thead>
</table>
<script src="../../../../static/lib/layuiadmin/layui/layui.js"></script>
<script src="../../../common/layuiInit.js"></script>
<script type="text/javascript" src="../../../common/common.js"></script>
<script type="text/javascript" src="../../../common/jquery-3.3.1.min.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    var selectRow,url;
    var wfActivity = JSON.parse(parent.$("#activity").val());
    var  taskId= RequestURLParam.getParam("taskId");
    layui.use('table', function () {
        var table = layui.table;
        table.init('formField', {
            height: '318',
            data: wfActivity
            ,page: false //开启分页
        });
        table.on('row(formField)', function(obj){
            selectRow = obj.data
        });

    });

    function getCheckData() {
        var id=selectRow.wfaId;
        url="/wf/systask/key/savewfnull";
        $.ajax({
            url: url,
            data:{
                activityId:id,
                id:taskId || 0
            },
            type: 'post',
            traditional: true,
            success: function (data) {
                if (data.OK == "OK") {
                    var userName = "";
                    if (data.operatorList != '' && data.operatorList != undefined) {
                        for (var i = 0; i < data.operatorList.length; i++) {
                            userName = userName + data.operatorList[i].userName + " ";
                        }
                        ;
                        layer.alert('流程跳转成功！申请已发送至【' + data.wfActivity.activityName + '】环节，并对用户【' + userName + '】发起了待办', {
                                icon: 1
                            }, function (i) {
                                layer.close(i)
                                if (parent.$("#layerNull").length > 0) {
                                    parent.parent.layer.close(parent.$("#layerNull").val())
                                    parent.parent.location.reload()
                                }
                            }
                        )
                    } else {
                        if (data.wfActivity != null && data.wfActivity.activityCode != undefined && data.wfActivity.activityCode == "end") {
                            layer.alert('流程跳转成功，流程已结束！', {
                                    icon: 1
                                }, function (i) {
                                    layer.close(i)
                                    location.reload()
                                    if (parent.$("#layerNull").length > 0) {
                                        parent.parent.layer.close(parent.$("#layerNull").val())
                                        parent.parent.location.reload()
                                    }
                                }
                            )
                        } else {
                            if (data.user == "null") {
                                layer.msg('提交失败！下一活动办理人找不到！', {
                                    icon: 2,
                                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                                }, function () {
                                })
                            } else {
                                layer.alert('流程跳转异常！请联系管理员！', {
                                        icon: 1
                                    }, function (i) {
                                        layer.close(i)
                                        location.reload()
                                        if (parent.$("#layerNull").length > 0) {
                                            parent.parent.layer.close(parent.$("#layerNull").val())
                                            parent.parent.location.reload()
                                        }
                                    }
                                )
                            }
                        }
                    }
                }
                else if (data.wfState == "over") {
                    layer.alert('请不要重复提交代办！', {
                            icon: 1
                        }, function (i) {
                            layer.close(i)
                            location.reload()
                            if (parent.$("#layerNull").length > 0) {
                                parent.parent.layer.close(parent.$("#layerNull").val())
                                parent.parent.location.reload()
                            }
                        }
                    )
                }
                else {
                    layer.msg('流程操作失败！', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                    })
                }
            },
            error: function () {
                layer.msg('流程操作失败！', {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function () {
                })
            }
        });
    }

</script>

</body>
</html>